package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC693 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public boolean hasAlternatingBits(int n) {
            int prev = -1, cur = 0;
            while (n > 0) {
                cur = n % 2;
                if (cur == prev) return false;
                n /= 2;
                prev = cur;
            }

            return true;
        }
    }

    public void run() {
        System.out.println(new Solution().hasAlternatingBits(1));
        System.out.println(new Solution().hasAlternatingBits(2));
        System.out.println(new Solution().hasAlternatingBits(5));
        System.out.println(new Solution().hasAlternatingBits(7));
        System.out.println(new Solution().hasAlternatingBits(11));
    }

    public static void main(String[] args) throws Exception {
        LC693 an = new LC693();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
